﻿using System;
using System.Web.Mvc;
using RedSand.Web.Mvc;
using RedSand.Site.Models;

namespace RedSand.Site.Controllers
{

    public class EmployeeController : BaseController
    {

		#region admin manager
        public JsonResult Gadget_EmployeeList()
        {
            return Json(RsDataManager.GetList<EmployeeInfo>("EmployeeGetAll"), JsonRequestBehavior.AllowGet);
        }
        public JsonResult Gadget_ReportList(int EmployeeID, int PageIndex=1, int PageSize=10)
        {
            return Json(RsDataManager.GetList<EmployeeReportInfo>("EmployeeReportGetList", new { EmployeeID = EmployeeID, PageIndex = PageIndex, PageSize = PageSize }), JsonRequestBehavior.AllowGet);
        }
        public JsonResult Gadget_ReportCount(int EmployeeID)
        {
            return Json(RsDataManager.ExecuteGetReturn("EmployeeReportCount", new { EmployeeID = EmployeeID }), JsonRequestBehavior.AllowGet);
        }
        public JsonResult Gadget_ReportCreate(EmployeeReportInfo info)
        {
            if (ModelState.IsValid)
            {
                info.CreateDate = DateTime.Now;
                return Json(RsDataManager.Save("EmployeeReportSave", info).ToString(), JsonRequestBehavior.AllowGet);
            }
            return Json(false, JsonRequestBehavior.AllowGet);
        }
        public JsonResult Gadget_ReportDelete(int id)
        {
            return Json(RsDataManager.Delete("EmployeeReportDelete", "ReportID", id).ToString(), JsonRequestBehavior.AllowGet);
        }
		#endregion
    }
}
